<include file="Public:header" />

<div class="container">
	<div class="row">
		<div class="panel talk-form">
			<div class="panel-heading">
			 	登录
		    </div>
	 		<form id="talk-login" action="{:U('user/login')}"  method="post" class="form-horizontal" >
				<div class="form-group">
					<label for="email" class="col-md-3 control-label">邮箱：</label>
					<div class="col-md-6">
						<input type="text" class="form-control" id="email" name="email" value="">
					</div>
				</div>
				<div class="form-group">
			        <label for="password" class="col-md-3 control-label">密码：</label>
			        <div class="col-md-6">
			        	<input type="password" class="form-control" id="password" name="password">
			        </div>
				</div>
				<div class="form-group">
					<div class="col-md-offset-3 col-md-4">
						<label for=""><input type="checkbox" name="is_remember" value="1"> 记住我</label>
					</div>
					<div class="col-md-2">
						<a href="{:U('user/password')}">忘记密码?</a>
					</div>
				</div>
				<div class="form-group">
					<div class="col-md-offset-3 col-md-6">
						<button type="submit" class="btn btn-primary">登录</button>
					</div>
				</div>
			</form>
		</div>
	</div>
</div>
<include file="Public:footer" />
<script>
	$("#talk-login").validate({
	    rules: {
	        email: {
	            required: true,
	            email: true
	        },
	        password: "required",
	    },
	    messages: {
	        email: {
	            required: "邮箱不能为空",
	            email: "邮箱格式不正确"
	        },
	        password: {
	            required: "密码不能为空"
	        }
	    },
	    submitHandler: function(e) {
	        $.ajax({
	            type: "POST",
	            dataType: "json",
	            url: "{:U('user/login')}",
	            data: $("#talk-login").serialize(),
	            success: function(data){
	            	if (data.status == 0) {
	            		bootbox.alert(data.info);
		            	return  false;
	            	} else {
	            		window.location.href = data.url;
	            	}

	            }
	        })
	    }
	});
</script>
</body>
</html>